//泛型初步
class ArrayList<T> {
    private T[] array;
    private int size;
    private static final int DEFAULT_CAPACITY = 10;

    // 构造函数
    public ArrayList() {
        array = (T[]) new Object[DEFAULT_CAPACITY];
        size = 0;
    }

    public void add(T e) {
        // 检查是否需要扩容，动态扩容
        if (size >= array.length) {
            resize();
        }
        array[size++] = e;
    }

    public T get(int index) {
        if (index < 0 || index >= size) {
            throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
        }
        return array[index];
    }

    // 扩容方法
    private void resize() {
        int newCapacity = array.length * 2;
        T[] newArray = (T[]) new Object[newCapacity];
        System.arraycopy(array, 0, newArray, 0, size);
        array = newArray;
    }

    public int size() {
        return size;
    }
}
class  Test {

}

public class main {
    public static void main(String[] args) {
        ArrayList<String> strList = new ArrayList<>();
        strList.add("a");
        strList.add("b");
        System.out.println(strList.get(1)); // 输出 "b"
        System.out.println(strList.get(0)); // 输出 "b"
        Test test = new Test();
        System.out.println(test.class);
        System.out.println(strList.class);
    }
}